from flask_wtf import FlaskForm
from wtforms import StringField,SubmitField,FloatField,IntegerField,FileField
from wtforms.validators import DataRequired
from flask_wtf.file import FileAllowed

class optionalForm(FlaskForm):
    cname = StringField(
        label='菜品名',
        validators=[
            DataRequired("菜品名不能为空!")
        ],
        render_kw={
            'placeholder':"请输入菜品名"
        }
    )

    cprice = FloatField(
        label='单价',
        validators=[
            DataRequired('输入格式不正确!'),
        ],
        render_kw={
            'placeholder':"请输入价格"
        }
    )

    points = IntegerField(
        label='积分',
        validators=[
            DataRequired('输入格式不正确!')
        ],
        render_kw={
            'placeholder':"请输入积分"
        }
    )

    ingredients = StringField(
        label='主料',
        render_kw={
            'placeholder':"请输入主料"
        }
    )

    taste = StringField(
        label='口味',
        render_kw={
            'placeholder':'请输入口味'
        }
    )

    type = StringField(
        label='分类',
        validators=[
            DataRequired('分类不能为空!')
        ],
        render_kw={
            'placeholder':'请输入分类'
        }
    )

    stock = IntegerField(
        label='库存',
        validators=[
            DataRequired('数据格式不正确!')
        ],
        render_kw={
            'placeholder':"请输入库存"
        }
    )

    images = FileField(
        label='图片',
        validators=[
            DataRequired('菜品图片不能为空!'),
            FileAllowed(['jpg','png'],'仅支持png和jpg格式的文件')
        ]
    )

    mealmeans = StringField(
        label='订餐方式',
        validators=[
            DataRequired('订餐方式不能为空!')
        ],
        render_kw={
            'placeholder':"请输入订餐方式"
        }
    )

    submit = SubmitField(
        label='确定'
    )